import 'package:flutter/material.dart';
import 'package:flutter_demo2/base/plugin/common_native.dart';

void main() {
  Future.delayed(const Duration(milliseconds: 500)).then((value) {
    commonNative.finishSplash();
  });
  return runApp(const MyApp());
}

///StatefulBuilder测试
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    debugPrint('YM------父控件刷新');
    return MaterialApp(
      title: 'Material App',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Material App Bar'),
        ),
        body: Center(
          child: Column(
            children: [
              _buildChild(),
              MaterialButton(
                onPressed: () {
                  _setter(() {
                    _count++;
                  });
                },
                child: const Text('第二种计数方式'),
              )
            ],
          ),
        ),
      ),
    );
  }
}

int _count = 0;
late StateSetter _setter;

_buildChild() => StatefulBuilder(
      builder: (BuildContext context, StateSetter setState) {
        _setter = setState;
        debugPrint('YM------子控件刷新');
        return Column(
          children: [
            Text('计数:$_count'),
            MaterialButton(
              onPressed: () {
                setState(() {
                  _count++;
                });
              },
              child: const Text('第一种计数方式'),
            )
          ],
        );
      },
    );
